# 家具类
class Furniture():
    def __init__(self,name,area):
        self.Furniture_name = name
        self.Furniture_area = area
# 房屋类
class Home():
    def __init__(self,address,area):
        #地理位置
        self._address = address
        #房屋面积
        self._area = area
        #剩余面积
        self.free_area = area
        # 家具列表
        self.furniture = []

    def __str__(self):
        return f'房子地理位置在{self._address}，房屋面积是{self._area}平方米,剩余面积{self.free_area}平方米,家具有{self.furniture}'

    def add_furniture(self,item):
        """容纳家具"""
        if self.free_area > item.Furniture_area:
            self.furniture.append(item.Furniture_name)
            # 家具搬入后，房屋剩余面积= 之前剩余面积 - 该家具面积
            self.free_area -= item.Furniture_area
        else:
            print('家具面积过大，房屋面积不足，无法容纳')

#双人床，6
bed = Furniture('双人床',6)
sofa = Furniture('沙发',5)

#房子1，北京，1000
jia = Home('北京',1200)
print(jia)
jia.add_furniture(bed)
jia.add_furniture(sofa)
print(jia)

ball = Furniture('篮球场',2000)
jia.add_furniture(ball)
print()





